<?php
ob_start();
session_start();
include "checksession.php";
date_default_timezone_set('Asia/Bangkok');
include("../connect.php");

$strSQL = "SELECT * FROM userlog WHERE id_member = '$id_member' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Adinop Co., Ltd. was founded as an ingredients importer and local manufacturers’ distributor in 1986. We also function as an exporter of finished products</title>
	  <link href="../images/it_service_logo.png" rel="shortcut icon" type="image/x-icon" />
      <link rel="stylesheet" href="../css/style.css"/>
	  <script language="javascript" src="../js/jquery/jquery-1.7.1.min"></script>
	  <script type="text/javascript" src="../fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
	  <script type="text/javascript" src="../fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	  <link rel="stylesheet" type="text/css" href="../fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
 	  <link rel="stylesheet" href="../fancybox/style.css" />
	  <script type="text/javascript" src="autocomplete.js"></script>
	  <link rel="stylesheet" href="autocomplete.css"  type="text/css"/>
	  
	  <script type="text/javascript"> 
		$(function(){
			var objSet="#show_arti_topic";
			var objSetText="ค้นหา รหัส,ชื่อ";
			if($(objSet).val()==""){
					$(objSet).val(objSetText);
			}	
			$(objSet).focus(function(){
				if($(objSet).val()==objSetText){
						$(objSet).val("");
				}	
			}).blur(function(){
				if($(objSet).val()==""){
						$(objSet).val(objSetText);
				}	
			});
		});
	   </script>
	  <script type="text/javascript">

		$(document).ready(function() {
		
			$('#webboardadd').fancybox({
				'width'				: '80%',
				'height'			: '80%',
				'autoScale'			: true,
				'scrolling'		    : 'auto',
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'overlayColor'		: '#000',
				'hideOnOverlayClick': false,
				onCleanup   : function() {
                return window.location.reload();
					 }
			});

			$('a[id^="question"]').fancybox({
					'width'				: '100%',
					'height'			: '100%',
					'autoScale'			: true,
					'scrolling'		    : 'auto',
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'none',
					'type'				: 'iframe',
					'overlayColor'		: '#000',
					'hideOnOverlayClick': false,
					onCleanup   : function() {
					return window.location.reload();
						 }
				});

		});
	</script>

    </head>
    <body> 
        <body class="body">
            <table align="center" width="90%">
                <tr>
                    <td colspan="2" class="header" >
                      <img src="../images/logo.png"> <img src="../images/it_service_text.png" width ="150">
                        <hr/>
                    </td>
                </tr >
                <tr  valign="top">
                    <td class="left">
                        <?php include_once "left.php"; ?>
                    </td>
                    <td>
                        <div align="right">
						<br/>
				<!--		<form id="myForm" method="get" action="search_recordPerson.php">
						<input name="show_arti_topic" type="text" id="show_arti_topic" />
						<input name="h_arti_id" type="hidden" id="h_arti_id" value="" />
						<input type="hidden" name="hidOK">
						 <input type="image" name="search" id="search" value="submit" src="../images/search.png">-->

				<!--		<a class="searchperson" id="searchperson" href="search_recordPerson.php"><img alt="searchperson" src="../images/search.png"/></a> -->
						</form>
						

						 <script type="text/javascript">
								function make_autocom(autoObj,showObj){
									var mkAutoObj=autoObj; 
									var mkSerValObj=showObj; 
									new Autocomplete(mkAutoObj, function() {
										this.setValue = function(id) {		
											document.getElementById(mkSerValObj).value = id;
										}
										if ( this.isModified )
											this.setValue("");
										if ( this.value.length < 1 && this.isNotClick ) 
											return ;	
										return "autocomplete_data.php?q=" +encodeURIComponent(this.value);
									});	
								}	
								 
								// การใช้งาน
								// make_autocom(" id ของ input ตัวที่ต้องการกำหนด "," id ของ input ตัวที่ต้องการรับค่า");
								make_autocom("show_arti_topic","h_arti_id");
								</script>
                         
							<a id="webboardadd" href="NewQuestion.php"><img alt="webboardadd" src="../images/question.png" width="45px" /></a>
                        </div>
					</div>
						<!--<a href="NewQuestion.php">New Topic</a>-->
<br/>
<?
include "../connect.php";
$strSQL = "SELECT * FROM webboard ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);

$Per_Page = 10;   // Per Page

$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
	$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
	$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
	$Num_Pages =($Num_Rows/$Per_Page)+1;
	$Num_Pages = (int)$Num_Pages;
}

$strSQL .=" order  by QuestionID DESC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
?>
<table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
  <tr>
    <th width="99"> <div align="center">ลำดับที่</div></th>
    <th width="458"> <div align="center">หัวข้อคำถาม</div></th>
    <th width="90"> <div align="center">ชื่อผู้แจ้ง</div></th>
    <th width="130"> <div align="center">วันที่แจ้ง</div></th>
    <th width="45"> <div align="center">View</div></th>
    <th width="47"> <div align="center">Reply</div></th>
  </tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
  <tr>
    <td><div align="center"><?=$objResult["QuestionID"];?></div></td>
    <td><a id="question<?=$i;?>" href="ViewWebboard.php?QuestionID=<?=$objResult["QuestionID"];?>"><?=$objResult["Question"];?></a></td>
    <td><?=$objResult["Name"];?></td>
    <td><div align="center"><?=$objResult["CreateDate"];?></div></td>
    <td align="right"><?=$objResult["View"];?></td>
    <td align="right"><?=$objResult["Reply"];?></td>
  </tr>
<?
}
?>
</table>

<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
	echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{
		echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
	}
	else
	{
		echo "<b> $i </b>";
	}
}
if($Page!=$Num_Pages)
{
	echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($connection);
?>
                    </td>
                </tr>  
               
                <tr>
                <td colspan="2">
                     <div><a href="../checklogout.php" onclick="return confirm('what do you want Exit')"> <img src="../images/logout.png" width="150px"></img></a></div>
                </td>
            </tr>
            <tr>
                <td class="footer" colspan="2">
                     Powered by Department Technology information Adinop
                </td>
            </tr>
            </table>
        </body>
</html>